home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-01
/
lcppb.zip
/
LCPP09.ZIP
/
POINTIN.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1991-07-08
|
1KB
|
55 lines
// pointin.cpp -- Demonstrate overloading input streams
//#include <stream.hpp>
#include <iostream.h>
class point {
private:
int x, y;
public:
point() { x = y = 0; }
point(int xx, int yy) { x = xx; y = yy; }
void putx(int xx) { x = xx; }
void puty(int yy) { y = yy; }
int getx(void) { return x; }
int gety(void) { return y; }
friend ostream& operator<<(ostream& os, point &p);
friend istream& operator>>(istream& is, point &p);
};
main()
{
point p;
cout << p << '\n';
p.putx(100);
p.puty(200);
cout << p << '\n';
cout << "\nEnter x and y values: ";
cin >> p;
cout << "\nYou entered: " << p;
}
ostream& operator<<(ostream& os, point &p)
{
os << "x == " << p.x << ", y == " << p.y;
return os;
}
istream& operator>>(istream& is, point &p)
{
is >> p.x >> p.y;
return is;
}
// Copyright (c) 1990 by Tom Swan. All rights reserved
// Revision 1.00 Date: 11/24/1990 Time: 11:56 pm
// Revision 1.01 Date: 07/08/1991 Time: 05:41 pm
// Converted for Borland C++ 2.0